from flask import Flask,Response

app = Flask(__name__)

@app.route('/')
def index():
    return 'Hello'

@app.route('/create_cookie/default/')
def create_cookie1():
    resp = Response('创建了一个默认的cookie')
    resp.set_cookie('uname','itbaizhan')
    return resp

@app.route('/create_cookie/max_age/')
def create_cookie2():
    resp = Response('创建了一个max_age的cookie')
    age  =60*60*2
    resp.set_cookie('uname','itbaizhan',max_age=age)
    return resp

from datetime import datetime
@app.route('/create_cookie/expires/')
def create_cookie3():
    resp = Response('创建了一个expires的cookie')
    tem_time = datetime(2025,10,15,17,10,10)
    resp.set_cookie('uname','itbaizhan',expires=tem_time)
    return resp

from datetime import timedelta
@app.route('/create_cookie/expires2/')
def create_cookie4():
    resp = Response('创建了一个expires的cookie')
    tem_time = datetime.now() + timedelta(days=2)
    resp.set_cookie('uname','itbaizhan',expires=tem_time)
    return resp

if __name__ == '__main__':
    app.run(debug=True)